package com.asnike.display{
	import flash.text.TextFieldAutoSize;
	import flash.text.TextFieldType;
	import flash.text.TextFormat;
	import flash.text.TextFormatAlign;

	public class ASTextArg{
		
		internal var contents:String = '';
		internal var autoSize:String = TextFieldAutoSize.NONE;
		internal var embed:Boolean;
		internal var isSelectable:Boolean;
		internal var isMouseEnabled:Boolean = true;
		internal var isMultiline:Boolean;
		internal var isBorder:Boolean;
		
		private var _data:Object = {format:new TextFormat};
		
		public function ASTextArg(){
		}
		public function text( $contents:String ):ASTextArg{
			if( _data.htmlText ){
				throw new Error( 'htmlText와 text 속성은 하나만 사용해야 합니다.' );
			}
			_data.text = $contents;
			return this;
		}
		public function htmlText( $contents:String ):ASTextArg{
			if( _data.text ){
				throw new Error( 'htmlText와 text 속성은 하나만 사용해야 합니다.' );
			}
			_data.htmlText = $contents;
			return this;
		}
		public function autoSizeLeft():ASTextArg{
			_data.autoSize = TextFieldAutoSize.LEFT;
			return this;
		}
		public function autoSizeRight():ASTextArg{
			_data.autoSize = TextFieldAutoSize.RIGHT;
			return this;
		}
		public function autoSizeCenter():ASTextArg{
			_data.autoSize = TextFieldAutoSize.CENTER;
			return this;
		}
		public function autoSizeNone():ASTextArg{
			_data.autoSize = TextFieldAutoSize.NONE;
			return this;
		}
		public function alignLeft():ASTextArg{
			_data.format.align = TextFormatAlign.LEFT;
			return this;
		}
		public function alignRight():ASTextArg{
			_data.format.align = TextFormatAlign.RIGHT;
			return this;
		}
		public function alignCenter():ASTextArg{
			_data.format.align = TextFormatAlign.CENTER;
			return this;
		}
		public function alignJustify():ASTextArg{
			_data.format.align = TextFormatAlign.JUSTIFY;
			return this;
		}
		public function size( $value:int ):ASTextArg{
			_data.format.size = $value;
			return this;
		}
		public function color( $value:uint ):ASTextArg{
			_data.format.color = $value;
			return this;
		}
		public function font( $name:String ):ASTextArg{
			_data.format.font = $name;
			return this;
		}
		public function bold( $value:Boolean = true ):ASTextArg{
			_data.format.bold = $value;
			return this;
		}
		public function italic( $value:Boolean = true ):ASTextArg{
			_data.format.italic = $value;
			return this;
		}
		public function underline( $value:Boolean = true ):ASTextArg{
			_data.format.underline = $value;
			return this;
		}
		public function selectable( $value:Boolean = false ):ASTextArg{
			_data.selectable = $value;
			return this;
		}
		public function mouseEnabled( $value:Boolean = false ):ASTextArg{
			_data.mouseEnabled = $value;
			return this;
		}
		public function multiline( $value:Boolean = true ):ASTextArg{
			_data.multiline = $value;
			return this;
		}
		public function embedFonts( $value:Boolean = true ):ASTextArg{
			_data.embedFonts = $value;
			return this;
		}
		public function leftMargin( $pixel:int ):ASTextArg{
			_data.format.leftMargin = $pixel;
			return this;
		}
		public function rightMargin( $pixel:int ):ASTextArg{
			_data.format.rightMargin = $pixel;
			return this;
		}
		public function indent( $value:int ):ASTextArg{
			_data.format.indent = $value;
			return this;
		}
		public function leading( $value:int ):ASTextArg{
			_data.format.leading = $value;
			return this;
		}
		public function border( $value:Boolean = true ):ASTextArg{
			_data.border = $value;
			return this;
		}
		public function borderColor( $value:int ):ASTextArg{
			_data.borderColor;
			return this;
		}
		public function maxChars( $value:int ):ASTextArg{
			_data.maxChars = $value;
			return this;
		}
		public function typeDynamic():ASTextArg{
			_data.type = TextFieldType.DYNAMIC;
			return this;
		}
		public function typeInput():ASTextArg{
			_data.type = TextFieldType.INPUT;
			return this;
		}
		
		internal function getData():Object{
			return _data;
		}
		
//------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
		public function getAutoSize():String{
			return _data.autoSize;
		}
		public function getTextSize():int{
			return int( _data.format.size );
		}
		public function getTextColor():uint{
			return uint( _data.format.color );
		}
		public function getTextAlign():String{
			return _data.format.align;
		}
		public function getHtmlText():String{
			return _data.htmlText;
		}
		public function getFont():String{
			return _data.format.font;
		}
		public function getEmbedFont():Boolean{
			return _data.embedFonts;
		}
		public function getBold():Boolean{
			return _data.format.bold;
		}
		public function getSelectable():Boolean{
			return _data.selectable;
		}
		public function getMouseEnabled():Boolean{
			return _data.mouseEnabled;
		}
		public function getItalic():Boolean{
			return _data.format.italic;
		}
		public function getUnderline():Boolean{
			return _data.format.underline;
		}
		public function getMultiline():Boolean{
			return _data.multiline;
		}
		public function getLeftMargin():Object{
			return _data.format.leftMargin;
		}
		public function getRightMargin():Object{
			return _data.format.rightMargin;
		}
		public function getIndent():Object{
			return _data.format.indent;
		}
		public function getLeading():Object{
			return _data.format.leading;
		}
		public function getBorder():Boolean{
			return _data.border;
		}
		public function getBorderColor():uint{
			return _data.borderColor;
		}
		public function getMaxChars():int{
			return _data.maxChars;
		}
		public function getType():String{
			return _data.type;
		}
	}
}